Skip to content

Delivery

The Delivery page in the application allows users to configure and manage delivery methods, primarily for sending out information via SMS or email. These configurations can then be used by AI agents or automation flows.

Overview

The page provides functionalities to:

  • Add new delivery configurations.
  • List existing delivery configurations, filtered by the selected agent.
  • Edit existing delivery configurations.
  • Associate delivery configurations with specific agents.
  • Delete delivery configurations.

Helper Buttons

  • Add Variable: Opens a dialog to create a new variable that can be used within your parser.
  • Lookup Names: Opens a dialog to look up the exact names of various Variables available for the selected agent.
  • AI Suggest Configuration: Opens a dialog to ask for a description and then uses AI to automatically build a suggested delivery configuration.

Delivery List

Adding a New Delivery

To add a new delivery configuration:

  1. Navigate to the Delivery page.
  2. Expand the "New Delivery" section.
  3. A form will appear with the following fields:
    • Lookup Names: (Button) Opens a dialog for looking up existing names of variables, prompts, APIs, etc., which can be useful when configuring delivery messages or parameters.
    • Name: (Text Input) A unique and descriptive name for this delivery configuration (e.g., "OrderConfirmationSMS", "NewsletterEmail").
    • Status: (Toggle) Activates or deactivates this delivery configuration. Default is True (active).
    • Agent(s): (Multiselect) Select one or more agents that will be able to use this delivery configuration.
    • Type: (Selectbox) The type of delivery. Options: send email, read email, send sms, read sms.
    • Method: (Selectbox) The service or method used for delivery. Email: Gmail API, Infobip, Microsoft Graph API, SendGrid. SMS: Telnyx (default for send sms), Twilio. Saving send sms with an email method, or send email with an SMS method, is blocked.
    • Connector: (Selectbox) An optional connector. For email methods (e.g., Microsoft Graph API or Infobip) it is the OAuth Connector that generates authentication tokens. For Telnyx it is an API Key connector holding the Telnyx API key; without one, the TELNYX_API_KEY agent variable or environment value is used. Twilio uses the TWILIO_ACCOUNT_SID / TWILIO_AUTH_TOKEN variables.
    • To: (Text Input) The recipient's address (phone number for SMS, email address for email). Supports embedding variables using {{var.variableName}}.
    • From: (Text Input) The sender's address (phone number for SMS, email address for email). Supports embedding variables. For SMS, use the sending number in E.164 (e.g., +15551234567); left blank, TELNYX_NUMBER or TWILIO_NUMBER is used.
    • CC: (Text Input) For email type only. Carbon Copy recipients. Supports embedding variables.
    • BCC: (Text Input) For email type only. Blind Carbon Copy recipients. Supports embedding variables.
    • Subject: (Text Input) For email type only. The subject line of the email. Supports embedding variables.
    • Body: (Text Area) The main content of the message (SMS text or email body). Supports embedding variables.
    • Opt Out: (Text Area) Text for opt-out instructions or links. Supports embedding variables.
    • Reply To: (Text Input) For email type only. The email address to which replies should be sent. Supports embedding variables.
    • Attachment Path: (Text Input) For email type only. Path to a file to be attached. Supports embedding variables.
    • Delivery Response Message: (Text Area) An optional message to return after the delivery is sent. If provided, this is considered a final response. Supports embedding variables.
  4. Click the "Create Delivery" button.
  5. Upon submission, the system stores the delivery configuration.

Listing Deliveries

Existing delivery configurations are listed under the "Deliveries" subheader.

  • Filtering: The list is automatically filtered to display deliveries associated with the globally selected agent (if an agent is selected).
  • Display: Each delivery configuration is shown in an expandable section, displaying its name, status (✅ for active, ❌ for inactive), and associated agents.
  • Details: Expanding a delivery's section reveals:
  • Type (sms/email)
  • Method
  • Connector (if used)
  • To address
  • From address
  • Subject (for email)
  • Delivery Response (if configured)
  • Each delivery entry has "Edit" and "Delete" buttons.

Editing a Delivery

To edit an existing delivery configuration:

  1. Click the "Edit" button next to the desired delivery in the list.
  2. The "Edit [Delivery Name]" form will appear, pre-filled with the delivery's current information.
  3. All fields from the "Add Delivery" form are available for modification. Additionally:
    • Lookup Names: (Button) Available for looking up system names.
    • Add Variable: (Button) Opens a dialog to quickly add a new variable if needed during configuration.
  4. Click "Save Changes" to update the delivery or "Cancel" to discard changes and hide the edit form.

Adding an Agent to a Delivery

If an agent is selected (via the global agent selector), a section appears allowing you to associate existing delivery configurations (that are not already associated with the selected agent) to that agent.

  • A dropdown lists "Available deliveries for [Selected Agent Name] Agent:".
  • Select a delivery configuration and click "Include delivery" to add the selected agent to that delivery's delivery_agents list.

Deleting a Delivery

To delete a delivery configuration:

  1. Click the "Delete" button next to the desired delivery in the list.
  2. Confirm the deletion when prompted. The delivery configuration will be permanently removed from the database.

This documentation should provide a good understanding of how to use the Delivery page.

Delivery Configuration Examples

Deliveries are configured depending on the delivery type selected. Different delivery types modify the field labels, help instructions, and relevant properties.


Example 1: Emailing a Stock Report (Send Email)

This example shows how to configure a delivery to email a generated stock analysis report to a user.

  • Name: stock report
  • Type: send email
  • Method: Microsoft Graph API
  • Connector: Microsoft-Graph-API
  • To: {{var.email}}
  • From: alan@pinionai.com
  • Subject: {{var.first_name}} - Your AI stock report
  • Body:
<p>
  Dear {{var.first_name}},<br />
  Thanks for your interest in pinionai.com.<br />
  Here is your report
</p>
<p>{{var.stock_analysis_response}}</p>

Example 2: Fetching Mail (Read Email)

Configure your agent to read emails from an IMAP mailbox, using an app password or login variables.

  • Name: read inbox emails
  • Type: read email
  • Method: Gmail API
  • Connector: Gmail_Connector
  • Login Username/Email: {{var.user_email_address}} (or an explicit address like user@gmail.com)
  • IMAP Server Address: imap.gmail.com
  • User Password: {{var.email_app_password}}
  • Read Parameters:
{
  "folder": "INBOX",
  "fetch_mode": "NEW",
  "port": 993
}

Example 3: Sending a Text Notification (Send SMS)

Deliver immediate SMS notifications using Telnyx (default) or Twilio.

  • Name: sms order alert
  • Type: send sms
  • Method: Telnyx
  • Connector: Telnyx_SMS (an API Key connector holding the Telnyx API key; leave blank to use the TELNYX_API_KEY variable. Twilio uses the TWILIO_* variables instead.)
  • To: {{var.customer_phone_number}}
  • From: +15551234567 (leave blank to use TELNYX_NUMBER / TWILIO_NUMBER)
  • Body: Hello {{var.first_name}}, your order #{{var.order_id}} has been shipped!
  • Opt Out: Reply STOP to opt out.

Example 4: Checking Text Messages (Read SMS)

Fetch incoming messages or query SMS logs. Read SMS polls Twilio's Messages API only; Telnyx texts arrive through the SMS webhook service instead (see SMS Channel).

  • Name: read customer feedback sms
  • Type: read sms
  • Method: Twilio
  • SMS Number: +15551234567
  • Base API Endpoint: https://api.twilio.com
  • User Auth Token: {{var.twilio_auth_token}}
  • Parameters:
{
  "account_sid": "ACxxxxxx",
  "fetch_limit": 50
}

Setup: Sending SMS with Telnyx

  1. In the Telnyx portal, buy or port a number, assign it to a messaging profile, and complete 10DLC (or toll-free) registration so US carriers accept your messages.
  2. On the Connectors page, add an API Key connector (e.g., Telnyx_SMS) and paste the Telnyx API key.
  3. On the Delivery page, create a send sms delivery with Method Telnyx, Connector Telnyx_SMS, and your Telnyx number as From.

If the send fails (for example, an unregistered number), the delivery returns no response message and the error is logged. When Response Variable is set, it receives the Telnyx message id. To let people text your agent and get answers back, run the SMS webhook service described in SMS Channel.


Setup: Configuring Microsoft Graph API for Email

The most modern and robust way to interact with an Outlook account is through the Microsoft Graph API. It's more secure than older methods because it uses OAuth 2.0 for authentication instead of just a username and password.

To register a Microsoft Graph API Application in Azure, you need to tell Microsoft that you have an application that wants to use its services.

  1. Go to the Azure Portal and sign in with your Microsoft account.
  2. Search for and select "Azure Active Directory".
  3. Go to "App registrations" and click "+ New registration".
  4. Name: Give it a name, like MyWebsiteEmailer.
  5. Supported account types: Choose "Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)".
  6. Click "Register".
  7. Take note of these two values on the overview page. You'll need them later:
    • Application (client) ID
    • Directory (tenant) ID

      (If you didn't note these, you can always find them by going to Azure Active Directory -> App registrations, clicking on your app, and viewing the "Overview" page.)

  8. Go to "Certificates & secrets".
  9. Click "+ New client secret". Give it a description (e.g., website-secret) and an expiration.
  10. IMPORTANT: Copy the Value of the secret immediately. You will never see it again after you leave this page.
  11. Go to "API permissions".
  12. Click "+ Add a permission", select "Microsoft Graph".
  13. Select "Application permissions" (NOT delegated permissions, because your server is acting on its own behalf).
  14. Search for Mail.Send and check the box next to Mail.Send.
  15. Search for Mail.Read and check the box next to Mail.Read.
  16. Search for Mail.ReadWrite and check the box next to Mail.ReadWrite.
  17. Click "Add permissions".
  18. Finally, you must click the "Grant admin consent for [Your Directory Name]" button and click "Yes". The status should change to "Granted".