Connect Your Website Chatbot to Real-Time APIs Using Custom Actions

In this article we're going to show you how you can use AI Custom Actions to access real-time data right from your chatbot using input from your chat visitors.  Custom actions are a powerful way to connect your AI-powered website chatbot to external APIs in real-time. Custom Actions let your chatbot dynamically pull in data, answer complex queries, and perform tasks automatically—enhancing customer interactions and automating common workflows.  With Custom AI actions you can lookup order statuses, give customers shipping dates, create tickets, or change account statuses.  This helps increase the number of customer service interactions that your chatbot can successfully close, and reduce the burden on your team.  

In this article, we'll guide you step-by-step through setting up Custom Actions using a Weather API as an example.

What are AI Custom Actions?

Custom Actions allow your chatbot to call external APIs based on specific triggers or keywords, fetch live data, and return responses instantly within the chat interface. You can:

  • Fetch data from external services like weather updates, order statuses, or customer details.
  • Trigger actions like creating tickets, scheduling appointments with Calendly or Cal, or updating records.
  • Personalize chatbot conversations by using dynamic responses and customer context.

AI Custom Actions

Getting Started

Step 1: Log In and Navigate to Custom Actions

The first step to setting up your Custom Actions is to login to Social Intents or sign up for a free trial.

AI Custom Actions dashboard

Click on  Apps from the left menu, then select your chatbot. Choose the AI Chatbot tab then the Custom Actions sub-tab.

Custom Actions

Step 2: Create a New Custom Action

Click  "Add Action" to create your first Custom Action.

You'll see a screen with several fields:

  • Action Type: Call API Request, Show Button or Iframe, Trigger on Chat Start
  • Action Name: The name of your custom action like get_weather
  • Method: Select GET, POST, PUT, or DELETE based on the API.
  • Endpoint URL: Add the API endpoint URL you'll call.
  • Parameters: Configure API parameters.
  • Request JSON template: JSON post data for POST, PUT, or DELETE actions
  • Request headers: These are custom headers to add to the request

Example: Real-Time Weather API Integration

We'll integrate with a weather API to fetch real-time weather information. We'll use OpenWeatherMap as an example.

Step 1: Get API Key from OpenWeatherMap

Step 2: Configure the Weather API Custom Action

  • Action Nameget_weather
  • When to useThis action is triggered when a visitor asks for the weather or anything about wind or rain or weather related in the chat. If I say, what's the temp in chicago? Then this should be triggered. If I follow up with, what about in Atlanta, then this is also a weather request.
  • Endpoint URLhttps://api.openweathermap.org/data/2.5/weather?q={{city}}&appid={{apikey}}&units=imperial
  • MethodGET

Configure parameters:

  • city (location/city): {{city}} (dynamic variable captured from user input)
  • apikey (API key): Your OpenWeatherMap API key

Example configuration:

Step 3: Define Response Handling

After making the API request, specify which fields your chatbot will display, or leave blank to allow all fields.

  • Temperature: {{main.temp}}
  • Weather description: {{weather.0.description}}
  • City name: {{name}}

Example Response:

<code>The current temperature in {{name}} is {{main.temp}}°C with {{weather.0.description}}.

Step 4: Testing Your Custom Action

Once you save your action, you can test your action using the Preview Button.  When a chat starts, you can type something like:  What's the weather in Los Angeles today?

Example Get Weather Custom Action

Activating Your Custom Action

Your AI Custom Action is now available for use in the chatbot.  You can always add or remove additional actions as needed.

Best Practices for Custom Actions

  • Clearly define your When to use criteria to avoid unintended API calls.
  • Secure your API keys and avoid exposing sensitive data in client-side scripts.
  • Regularly monitor API usage limits and performance.
  • Clearly handle errors with user-friendly messages.

Conclusion

With AI Custom Actions, your chatbot becomes smarter and more powerful, enabling dynamic and personalized user interactions. Start integrating your chatbot today and deliver an exceptional experience to your website visitors.

Need more help? Reach out to our support team—we're here to assist!