NetBox is an open source web application designed to help manage and document computer networks. This use case will show you how to query device using Slack Application to query Netbox. For configuration of Slack application with OAuth please follow Youtube video here.

Lets create POST endpoint called /webhook/netbox inside of the block and add the following script.

# Variables
NETBOX_URL="https://your-netbox-instance/api"

device_name=$FORM_TEXT
# CRED_API_TOKEN is CRED saved in RapidForge instance
response=$(curl -s -G \
  -H "Authorization: Token $CRED_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data-urlencode "name=$device_name" \
  "$NETBOX_URL/dcim/devices/")

device_count=$(echo "$response" | jq '.count')

if [ "$device_count" -eq 0 ]; then
  echo "No device found with the name: $device_name"
else
  echo "Device(s) found:"
  echo "$response" | jq '.results[] | {name: .name, id: .id, device_type: .device_type.display, site: .site.name}'
fi

After Oauth configuration you need to define command in Slack Application's settings. Lets define command /device and put request url endpoint that you defined. With this we added Slack application to Netbox and we can use it to query Netbox.