πŸ“’Broadcast Messages (via web or API)

After you've connected your copilot to Slack or WhatsApp, you can send custom messages to your users to notify them of relevant news, reengage inactive users, and more!

Using the Web-Based Graphical Interface

Navigate to the integrations tab on the published run that you've connected. Expand "Configure Settings πŸ› οΈ" and scroll to the bottom of the settings. For supported integration types like Slack and WhatsApp, you should see the following input widget:

Enter your message and upload audio, video, and other documents as desired. Make sure the file type is supported by the relevant platform. WhatsApp currently supports audio/aac, audio/mp4, audio/mpeg, audio/amr, and audio/ogg. Slack has best support for audio/mp4 or audio/mpeg. Once you're ready to send the messages, click "Send Broadcast" and you'll be prompted for confirmation. Upon confirmation, the messages will start sending. Depending on how many users you have, it can take a few minutes for all of them to be notified.

Note that WhatsApp restricts free-form message sending to users who have contacted you within the last 24 hours to prevent spam. To sidestep this issue, you can have your message templates approved by WhatsApp. To do this, you must use a custom WhatsApp business integration on Gooey and not one were we manage the number for you. If you have questions, don't hesitate to contact us via support@gooey.ai.

Programmatic Access via API

The API supports a few extra features including only sending the message to some subset of users or adding custom buttons. To get started, click the API link (either here or from the integration tab shown above) to view the API documentation for message broadcasting.

Specifying which Integration to Broadcast through

You'll use some combination of the example_id and run_id query parameters to specify which of your connected published runs you want to broadcast through. These are the same parameters you'll see in the URL on Gooey.AI when you are editing your run or on the integrations tab. To find your run, find it in your history and click on the title to activate it. Then inspect the url, e.g. "https://gooey.ai/copilot/farmerchat-with-vision/?example_id=nuwsqmzp" -- in this case we only have the "example_id" query parameter so "https://api.gooey.ai/v2/video-bots/broadcast/send/?example_id=nuwsqmzp" would be our API endpoint URL.

Example Code

Once you have your API endpoint, you are ready to start making requests. Here's some sample code in Python, NodeJS and via CURL:

# $ python3 -m pip install requests
# $ export GOOEY_API_KEY=sk-xxxx

import os
import requests

payload = {"text": "Hi, we've launched a new feature: you can now upload photos of your crops and ask questions about them!"}

response = requests.post(
    "https://gooey.ai/copilot/farmerchat-with-vision/?example_id=nuwsqmzp",
    headers={
        "Authorization": "Bearer " + os.environ["GOOEY_API_KEY"],
    },
    json=payload,
)
assert response.ok, response.content

result = response.json()
print(response.status_code, result)
// $ npm install node-fetch
// $ export GOOEY_API_KEY=sk-xxxx

import fetch from 'node-fetch';

const payload = {"text": "Hi, we've launched a new feature: you can now upload photos of your crops and ask questions about them!"};

async function gooeyAPI() {
  const response = await fetch("https://gooey.ai/copilot/farmerchat-with-vision/?example_id=nuwsqmzp", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + process.env["GOOEY_API_KEY"],
      "Content-Type": "application/json",
    },
    body: JSON.stringify(payload),
  });

  if (!response.ok) {
    throw new Error(response.status);
  }

  const result = await response.json();
  console.log(response.status, result);
}

gooeyAPI();
# export GOOEY_API_KEY=sk-xxxx

curl 'https://gooey.ai/copilot/farmerchat-with-vision/?example_id=nuwsqmzp' \
  -H "Authorization: Bearer $GOOEY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "Hi, we have launched a new feature: you can now upload photos of your crops and ask questions about them!"
}'

Filtering Users

To only broadcast messages to certain subsets of users, we provide some filter options. These include

  • "wa_phone_number__in": list[string],

  • "slack_user_id__in": list[string],

  • "slack_user_name__icontains": string,

  • "slack_channel_is_personal": boolean

They can be added to the filter object of the payloads in the above example code. For example, to only broadcast to the WhatsApp accounts with phone numbers "1234" and "+1 (420) 666-6969", you could modify the payload to the following:

payload = {
    "text": "Hi, we've launched a new feature: you can now upload photos of your crops and ask questions about them!",
    "filters": {
        "wa_phone_number__in": ["1234", "+1 (420) 666-6969"]
    }
}

Last updated