# llInstantMessage

*LSL function*

```lsl
void llInstantMessage(key agent, string msg);
```

- `key agent`: UUID of the destination agent.
- `string msg`: Text message string to send.

- Delay: 2 s
- Energy: 10

Sends an Instant Message specified in the [string](https://wiki.secondlife.com/wiki/string) `message` to the user specified by `user`.

To send a message directly to an [object](https://wiki.secondlife.com/wiki/object), use [llRegionSayTo](/functions/llRegionSayTo/).

```lsl title="How to use" frame="terminal"
llInstantMessage(NULL_KEY, "");
```

## Caveats

- All [object](https://wiki.secondlife.com/wiki/object) IMs are throttled at a maximum of 2500 per 30mins, per owner, per [region](https://wiki.secondlife.com/wiki/region), in a rolling window. This includes IMs sent after the throttle is in place.
  - Throttled IMs are dropped. for implementation see [notes](/functions/llInstantMessage/#notes) below.
- Messages longer than 1023 bytes will be truncated to 1023 bytes[^wiki-d9c93e]. This can convey 1023 ASCII characters, or fewer[^wiki-20920f] if non-ASCII characters are present.

- If the specified user is logged in, **message** will appear in the chat window and will not logged by the InstantMessage logging facility.
- If the specified user is not signed in, the messages will be delivered to their email just like a regular instant message, if the user has enabled email for their account.
  - If messages are sent to the same user by the same object within about 65 seconds, they will be bundled together in a single email.

[^wiki-d9c93e]: As of Feb 26th, 2013, in all sims, instant messages are now truncated to 1023 bytes to prevent certain types of delivery failure. (See [Release Notes for Second Life Server 13.02.15.270481](https://wiki.secondlife.com/wiki/Release_Notes/Second_Life_Server/13#13.02.15.270481)).
[^wiki-20920f]: Around 512 UTF-8 characters such as **á**.

## Examples

<details open>
<summary>Tell the owner somebody touched the object:</summary>

```lsl
default
{
    touch_start( integer total_num )
    {
        llInstantMessage( llGetOwner(), "Someone touched me" );
    }
}
```

</details>

<details>
<summary>Send an IM to a detected avatar only</summary>

```lsl
default
{
    touch_start( integer total_num )
    {
        llInstantMessage( llDetectedKey(0), "Hands Off!");
    }
}
```

</details>

## Notes

- [llRegionSayTo](/functions/llRegionSayTo/) may be a better choice if the target is in the same region as the object sending the message, as it has no built-in delay and can communicate directly with objects, as well as with avatars and their attachments.
- Instant Messaging allows communication from an object to an avatar anywhere on the Grid. However, an object cannot receive an Instant Message.
- Using [llInstantMessage](/functions/llInstantMessage/) from one or more child scripts will avoid delays in the main script. Child scripts will still be subject to delays, [message queue](https://wiki.secondlife.com/wiki/LSL_Event_Queue) limits, and region throttles.
- Throttling Implementation (Kelly Linden):
- The throttle is on all IMs from the object owner. It does not disable all IMs in the region, but does disable all IMs from the owner of the object.
- The throttle is not per object, but per owner. Splitting the spamming object into multiple objects will not help unless owned by different people. This also means that owning multiple almost too spammy objects will cause you to hit the limit.
- 2500 IMs in 30 minutes will trigger the block.
- IMs that are blocked continue to count against the throttle. The IM count must drop below 2500 before any IMs will be delivered.
- The IM count of the previous window is used to approximate the rolling window. If it is 20% into the current window the IM count will be the current count + 80% of the previous count. This allows us to approximate a rolling average, however it has the behavior that a flood of IMs can have an effect on the throttle for double the window length. This is why in practice the throttle behaves more like 5k in 1hr than 2.5k in 30min.

## Known issues

From the issue templates included by the wiki article:

- SVC-92 (nf): **llTargetSay**() - region-wide direct communication

## See also

### Functions

- [llOwnerSay](/functions/llOwnerSay/) — Sends chat region wide to owner
- [llRegionSay](/functions/llRegionSay/) — Sends chat region wide
- [llRegionSayTo](/functions/llRegionSayTo/) — Sends chat region wide to a specific prim/avatar
- [llWhisper](/functions/llWhisper/) — Sends chat limited to 10 meters
- [llSay](/functions/llSay/) — Sends chat limited to 20 meters
- [llShout](/functions/llShout/) — Sends chat limited to 100 meters

---

*Source: [LlInstantMessage](https://wiki.secondlife.com/wiki/LlInstantMessage) on the Second Life Wiki. Content from the Second Life Wiki articles LlInstantMessage (revision 1210711, 2022-04-30), Template:Issues/SVC-92 (revision 1142929, 2011-05-09), Template:LSL Function/avatar (revision 1179236, 2013-06-15) and Template:LSL Function/chat (revision 1192932, 2014-08-23), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llInstantMessage/
