Class MessagingTools

java.lang.Object
com.tnsai.tools.communication.MessagingTools

public class MessagingTools extends Object
Function-shape messaging tools — the LangChain-style replacement for the legacy SlackWebhookTool, DiscordWebhookTool, TwilioSMSTool, and TwilioStatusTool. See issue #188.

Four typed @Tool methods on a single POJO:

MethodBackendAuthIdempotent
slackPost(java.lang.String, java.lang.String)Slack incoming webhookSLACK_WEBHOOK_URL✗
discordPost(java.lang.String, java.lang.String, java.lang.String, boolean)Discord webhookDISCORD_WEBHOOK_URL✗
twilioSmsSend(java.lang.String, java.lang.String, java.lang.String)Twilio RESTSID + AUTH_TOKEN basic-auth✗
twilioSmsStatus(java.lang.String)Twilio RESTSID + AUTH_TOKEN basic-auth✓

Like EmailTools, all credentials are constructor-injected. Each method that needs a credential the POJO doesn't have throws IllegalStateException naming the missing env var, so an agent configured for Slack-only can register the POJO with the Discord and Twilio methods raising clear errors only on call.

Since:
0.5.7 (Phase 2 batch 6b — built-in tool migration to function shape, see #188)
  • Constructor Details

    • MessagingTools

      public MessagingTools()
      Default constructor — reads every credential from the environment.
  • Method Details

    • slackPost

      @Tool(name="slack_post", description="DESTRUCTIVE: post a message to a Slack channel via the configured incoming webhook URL. Optional {channel} overrides the webhook\'s default channel (e.g. \"#releases\", \"@username\"). Requires SLACK_WEBHOOK_URL.", keywords={"slack","post","message","channel","notification"}) public String slackPost(@ToolParam(description="Message text \u2014 supports Slack markdown (mrkdwn)") String text, @ToolParam(description="Channel override (e.g. \"#general\", \"@user\"); blank uses the webhook default",required=false,defaultValue="") String channel) throws IOException
      Throws:
      IOException
    • discordPost

      @Tool(name="discord_post", description="DESTRUCTIVE: post a message to a Discord channel via the configured webhook URL. Optional {username} and {avatarUrl} override the webhook\'s defaults; {tts} enables Discord text-to-speech (defaults to false). Requires DISCORD_WEBHOOK_URL.", keywords={"discord","post","message","webhook","notification"}) public String discordPost(@ToolParam(description="Message content (1..2000 chars; Discord limit)") String content, @ToolParam(description="Override the webhook\'s default username; blank uses default",required=false,defaultValue="") String username, @ToolParam(description="Override the webhook\'s default avatar URL; blank uses default",required=false,defaultValue="") String avatarUrl, @ToolParam(description="Send as Discord text-to-speech message (default false)",required=false,defaultValue="false") boolean tts) throws IOException
      Throws:
      IOException
    • twilioSmsSend

      @Tool(name="twilio_sms_send", description="DESTRUCTIVE: send an SMS via the Twilio REST API. {to} is the recipient phone number in E.164 format (e.g. \"+15551234567\"). Optional {from} overrides the configured TWILIO_FROM number. Body is capped at 1600 characters (Twilio\'s concatenated-SMS limit). Returns the Twilio message SID for follow-up via twilio_sms_status. Requires TWILIO_ACCOUNT_SID + TWILIO_AUTH_TOKEN + TWILIO_FROM.", keywords={"twilio","sms","send","message","phone"}) public Map<String,Object> twilioSmsSend(@ToolParam(description="Recipient phone number in E.164 format (e.g. \"+15551234567\")") String to, @ToolParam(description="SMS body (1..1600 chars)") String body, @ToolParam(description="Override sender phone number (E.164); blank uses configured TWILIO_FROM",required=false,defaultValue="") String from) throws IOException
      Throws:
      IOException
    • twilioSmsStatus

      @Tool(name="twilio_sms_status", description="Fetch the delivery status of a Twilio SMS by message SID (returned from twilio_sms_send). Returns {sid, to, from, status, errorCode?, errorMessage?} where status is one of queued / sending / sent / failed / delivered / undelivered. Read-only.", keywords={"twilio","sms","status","delivery"}, idempotent=true) public Map<String,Object> twilioSmsStatus(@ToolParam(description="Twilio message SID returned by twilio_sms_send (starts with \"SM\")") String messageSid) throws IOException
      Throws:
      IOException